package org.example4;

import java.lang.reflect.Method;
/*
https://segmentfault.com/a/1190000021269568
合成方法:ACC_SYNTHETIC 不存在于源码中,是jvm动态合成的

Any constructs introduced by the compiler that do not have a corresponding construct in the source code
must be marked as synthetic, except for default constructors and the class initialization method.

 */
public  class SyntheticDemo {

    public static void main(String[] args) throws Exception{

        InnerClass innerObject = new InnerClass();
        System.out.println("inner: " + innerObject.inner);

        System.out.println(innerObject.getClass());

        Method[] declaredMethods = innerObject.getClass().getDeclaredMethods();
        for (Method method : declaredMethods) {
            System.out.println(method + "----------是否为合成方法:" + method.isSynthetic());
            method.invoke(null, innerObject);
            System.out.println("------------");
        }

//        Method[] declaredMethods = SyntheticDemo$InnerClass.class.getDeclaredMethods();


    }

    private static class InnerClass{

//        String inner = "我在内部";
        private String inner = "我在内部";
    }
}